import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

"""
   通过random 中的 state 来控制对应位置的suffer
"""
if __name__ == '__main__':
    sns.set_style('whitegrid')

    axs = plt.figure()

    x = np.random.uniform(0, 10, 10)

    y = x * 0.83 + 0.6

    with sns.axes_style('whitegrid'):
        axs_1 = axs.add_subplot(1, 2, 1)
        axs_1.plot(x, y)

    print('shuffle 前:', x, y)

    # random state 保存suffer的顺序结构
    state = np.random.get_state()
    np.random.shuffle(x)
    np.random.set_state(state)
    np.random.shuffle(y)

    with sns.axes_style('darkgrid'):
        axs_2 = axs.add_subplot(1, 2, 2)
        axs_2.plot(x, y)

    print('shuffle 后:', x, y)
    axs.show()